package com.css.dzj.dzjfxyj.common.menu;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.css.aq.server.service.BaseService;
import com.css.dzj.dzjfxyj.common.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/org")
public class GetOrgController {
    @Autowired
    private BaseService baseService;
    @Autowired
    private HttpServletRequest request;

    @GetMapping("/getOrg")
    public R getMenu(){

        Map map= baseService.listOrgMenu(0L);
       /* String url = BASE_URL+BASE_API_MENU;

        R data = serviceUtil.getInfoFromBase(url, null, true, false);
//        System.out.println(data.acquier("data"));
        JSONObject menuData = (JSONObject) JSON.parse(data.get("data").toString());
//        System.out.println(menuData.acquier("result"));
        JSONArray menuInfo = (JSONArray) menuData.get("result");
        //      System.out.println(menuInfo);

        JSONArray fastBtn = new JSONArray();
        addFastEntry(menuInfo, fastBtn);*/
        JSONArray jsonArray=(JSONArray)map.get("result");
        Object org=jsonArray.get(0);
        //List list=new ArrayList();
        //list.add(org);
        String data= JSON.toJSONString(org);
        //JSONArray object=(JSONArray) JSON.parse(data);
        return R.ok().put("data", data);
    }
}
